//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "ArffPatternRecord.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <fstream>
#include <iostream>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define MAX_SIZE 500000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ArffPatternRecord::ArffPatternRecord () {

  this->type     = new String ();
  this->pattern  = new String ();
  this->position = 0;
  this->toString = new String ();

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ArffPatternRecord::ArffPatternRecord (const ArffPatternRecord& arffPatternRecord) {

  this->type     = new String (arffPatternRecord.type);
  this->pattern  = new String (arffPatternRecord.pattern);
  this->position = arffPatternRecord.position;
  this->toString = new String (arffPatternRecord.toString);

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ArffPatternRecord::ArffPatternRecord (const ArffPatternRecord* arffPatternRecord) {

  this->type     = new String (arffPatternRecord->type);
  this->pattern  = new String (arffPatternRecord->pattern);
  this->position = arffPatternRecord->position;
  this->toString = new String (arffPatternRecord->toString);

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ArffPatternRecord::~ArffPatternRecord () {

  if (this->type    ) delete this->type;
  if (this->pattern ) delete this->pattern;
  if (this->toString) delete this->toString;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void ArffPatternRecord::Type (String* type) {

  if (type)
    *(this->type) = *type;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void ArffPatternRecord::Pattern (String* pattern) {

  if (pattern)
    *(this->pattern) = *pattern;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void ArffPatternRecord::Position (int position) {

  this->position = position;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

String* ArffPatternRecord::Type (void) {

  return this->type;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* ArffPatternRecord::Pattern (void) {

  return this->pattern;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int ArffPatternRecord::Position (void) {

  return this->position;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* ArffPatternRecord::ToString (void) {

  char buffer [MAX_SIZE];
  
  sprintf(buffer, "%d %s %s\0", this->position, this->type->Out(), this->pattern->Out());
  this->toString->In(buffer);
  
  return this->toString;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ArffPatternRecord ArffPatternRecord::operator= (const ArffPatternRecord& arffPatternRecord) {

  *(this->toString) = *(arffPatternRecord.toString);
  *(this->type   )  = *(arffPatternRecord.type);
  *(this->pattern)  = *(arffPatternRecord.pattern);
  this->position    = arffPatternRecord.position;

  return *this;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
